package backend.project.gym_management.pojo.dto;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.AssertTrue;
import javax.validation.constraints.NotNull;

/**
 * 管理员删除功能参数
 */
@Data

public class AdminDeleteParam {
    @ApiModelProperty(value = "要删除表格的名字",required = true, example = "user")
    @NotNull
    private String tableName;

    @ApiModelProperty(value = "要删除的id（可选）", example = "1")
    private Integer id;

    @ApiModelProperty(value = "要删除的姓名/名称（可选）", example = "zhangsan")
    private String name;

    @ApiModelProperty(value = "要删除的uid（可选）", example = "1")
    private Integer uid;

    // 校验逻辑：id 或 name 必须至少有一个不为空
    @AssertTrue(message = "必须提供 id 或 name 中的一个")
    public boolean isIdOrNameProvided() {
        return id != null || name != null || !name.trim().isEmpty();
    }
}
